package com.atguigu.juc_day01.ticket_demo;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * java
 * 2022/9/6 20 10
 */
public class TrainTicket {
    private int number = 60;
    Lock lock = new ReentrantLock (true);
    public void sale(){
        lock.lock ();
        if (number>0){
            System.out.println (Thread.currentThread ().getName ()+"买的-"+"目前剩余"+--number+"张票");
        }
        lock.unlock ();
    }
}
